<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .aclass {
            color: blue;
        }
    </style>
</head>

<body>
    <div id="hello">
        <!-- 对象语法，：后面为true的时候，才属于这个类 -->
        <h2 v-bind:class="{aclass: isaclass,bclass: isbclass}">{{message}}</h2>

        <!-- 通过一个方法返回对象语法,先写一个固定类名，后面写个对象语法 -->
        <h2 class="title"  v-bind:class="getClass()">{{message}}</h2>

        <button v-on:click="handle1">change color</button>
    </div>
    <script src="../vue.js"></script>
    <script>
        const vue01 = new Vue({
            el: '#hello',
            data: {
                message: 'hello vuejs',
                isaclass: true,
                isbclass: true
            },
            methods: {
                handle1: function () {
                    this.isaclass = !this.isaclass;
                },
                getClass: function() {
                    return {
                        aclass: this.isaclass,
                        bclass: this.isbclass
                    }
                }

            }
        })
    </script>
</body>

</html>